package io.transaction.spring.service;

import io.transaction.spring.dao.ProductDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Service
public class ProductService {

    @Autowired
    private ProductDao productDao;

    // @Transactional(propagation = Propagation.REQUIRED) // 实践一：只在内部方法加事务注解，内部方法执行失败，不影响外部方法
    public void updateProductStockCountById(Integer stockCount, Long id) { // 内部方法
        productDao.updateProductStockCountById(stockCount, id);
        int i = 1 / 0;
    }
}
